home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 426-450 / disk_438 / toollib / source / support.s < prev   
Text File  |  1992-05-06  |  5KB  |  179 lines

  1.                 opt     l+,o+,ow-
  2. *
  3. *   support.s version 7.6 - © Copyright 1990 Jaba Development
  4. *
  5. *   Author    : Jan van den Baard
  6. *   Assembler : Devpac version 2.14
  7. *
  8. *   library support routines.
  9. *
  10.  
  11.                 incdir  'sys:devpac_inc/'
  12.                 include 'mymacros.i'
  13.                 include 'exec/exec_lib.i'
  14.  
  15. *
  16. * Format routine for "GetDate" which gets it's arguments from the stack.
  17. *
  18.                 xdef    DoFmt
  19.  
  20. DoFmt:          movem.l a2-a3/a6,-(sp)
  21.                 move.l  16(sp),a3
  22.                 move.l  20(sp),a0
  23.                 lea.l   24(sp),a1
  24.                 move.l  #DoBuf,a2
  25.                 move.l  (_SysBase).w,a6
  26.                 libcall RawDoFmt
  27.                 movem.l (sp)+,a2-a3/a6
  28.                 rts
  29.  
  30. *
  31. * This gets called by "RawDoFmt". When called A3 contains the buffer pointer
  32. * and d0 contains the next formatted character.
  33. *
  34.                 xdef    DoBuf
  35.  
  36. DoBuf:          move.b  d0,(a3)+
  37.                 rts
  38.  
  39. *
  40. * Find the last occurance of a character in a string. A0 must point to a
  41. * null terminated string. D0 must contain the character looked for. When
  42. * the routine finds the character the addres is returned else null is
  43. * returned.
  44. *
  45.                 xdef    CharRight
  46.  
  47. CharRight:      movea.l a0,a1
  48. RFindEnd:       tst.b   (a0)+
  49.                 bne.s   RFindEnd
  50. RFindChar:      cmpa.l  a0,a1
  51.                 beq.s   RNotFound
  52.                 cmp.b   -(a0),d0
  53.                 bne.s   RFindChar
  54.                 move.l  a0,d0
  55.                 rts
  56. RNotFound:      cldat   d0
  57.                 rts
  58.  
  59. *
  60. * Find the first occurance of a character in a string. A0 must point to a
  61. * null terminated string. D0 must contain the character looked for. When
  62. * the routine finds the character the addres is returned else null is
  63. * returned.
  64. *
  65.                 xdef    CharLeft
  66.  
  67. CharLeft:       movea.l a0,a1
  68. LFindEnd:       tst.b   (a1)+
  69.                 bne.s   LFindEnd
  70. LFindChar:      cmpa.l  a0,a1
  71.                 beq.s   LNotFound
  72.                 cmp.b   (a0)+,d0
  73.                 bne.s   LFindChar
  74.                 move.l  a0,d0
  75.                 dec.l   d0
  76.                 rts
  77. LNotFound:      cldat   d0
  78.                 rts
  79.  
  80. *
  81. * Copy a null terminated string into a buffer. A0 must point to the buffer.
  82. * A1 must point to the null terminated string to be copied.
  83. *
  84.                 xdef    StrCpy
  85.  
  86. StrCpy:         move.b  (a1)+,(a0)+
  87.                 tst.b   (a1)
  88.                 bne.s   StrCpy
  89.                 move.b  #0,(a0)
  90.                 rts
  91.  
  92. *
  93. * Convert a lower case alphabetical character into upper case.
  94. * D0 must contain the character.
  95. *
  96.                 xdef    ToUpper
  97.  
  98. ToUpper:        cmp.b   #'a',d0
  99.                 bmi.s   NotLoAlp
  100.                 cmp.b   #'z',d0
  101.                 bhi.s   NotLoAlp
  102.                 sub.b   #' ',d0
  103. NotLoAlp:       rts
  104.  
  105. *
  106. * Convert a upper case alphabetical character into lower case.
  107. * D0 must contain the character.
  108. *
  109.                 xdef    ToLower
  110.  
  111. ToLower:        cmp.b   #'A',d0
  112.                 bmi.s   NotUpAlp
  113.                 cmp.b   #'Z',d0
  114.                 bhi.s   NotUpAlp
  115.                 add.b   #' ',d0
  116. NotUpAlp:       rts
  117.  
  118. *
  119. * Calculate the length of a null terminated string. A0 must be a pointer
  120. * to a null terminated string. The length of the string, without the null
  121. * byte, is returned in D0.
  122. *
  123.                 xdef    StrLen
  124.  
  125. StrLen:         cldat   d0
  126. SizeLoop:       tst.b   (a0)+
  127.                 beq.s   HaveSize
  128.                 inc.l   d0
  129.                 bra.s   SizeLoop
  130. HaveSize:       rts
  131.  
  132. *
  133. * Compare two strings (case dependant). A0 must point to a null terminated
  134. * string. A1 must point to a null terminated string. -1, 0 or 1 is returned
  135. * depending on wether the string in A0 is to be considerd smaller, equal or
  136. * bigger than the string in A1.
  137. *
  138.  
  139.                 xdef    StrCmp
  140.  
  141. StrCmp:         move.b  (a0)+,d0
  142.                 tst.b   d0
  143.                 beq.s   Smaller
  144.                 cmp.b   (a1)+,d0
  145.                 blo.s   Smaller
  146.                 bhi.s   Bigger
  147.                 tst.b   d0
  148.                 bne.s   StrCmp
  149.                 cldat   d0
  150.                 rts
  151. Smaller:        moveq   #-1,d0
  152.                 rts
  153. Bigger:         moveq   #1,d0
  154.                 rts
  155.  
  156. *
  157. * Compare two strings (case independant). A0 must point to a null terminated
  158. * string. A1 must point to a null terminated string. -1, 0 or 1 is returned
  159. * depending on wether the string in A0 is to be considerd smaller, equal or
  160. * bigger than the string in A1.
  161. *
  162.                 xdef    StriCmp
  163.  
  164. StriCmp:        move.b  (a0)+,d0
  165.                 bsr     ToLower
  166.                 move.b  d0,d1
  167.                 tst.b   d1
  168.                 beq.s   Smaller
  169.                 move.b  (a1)+,d0
  170.                 bsr     ToLower
  171.                 cmp.b   d0,d1
  172.                 blo.s   Smaller
  173.                 bhi.s   Bigger
  174.                 tst.b   d1
  175.                 bne.s   StriCmp
  176.                 cldat   d0
  177.                 rts
  178.  
  179.